package main

import (
	"fmt"
	"gitee.com/bean_xc/gosdf"
)

var enginePath = "/home/piico_ccmu_driver_v1.1-r673c/lib/libpiico_ccmu.so"

func main() {
	if err := gosdf.Init(enginePath); err != nil {
		fmt.Println("SDF Init error:", err)
		return
	}
	defer gosdf.Exit()

	session, ret := gosdf.OpenSession()
	if ret != gosdf.SDR_OK {
		fmt.Println("SDF Open Session error")
		return
	}
	defer gosdf.CloseSession(session)

	if ret := gosdf.Sm3Init(session); ret != gosdf.SDR_OK {
		fmt.Println("SM3 Init error:", ret)
		return
	}

	//55E12E91650D2FEC56EC74E1D3E4DDBFCE2EF3A65890C2A19ECF88A307E76A23
	if ret := gosdf.Sm3Update(session, []byte("test")); ret != gosdf.SDR_OK {
		fmt.Println("SM3 Update error:", ret)
	}

	hash, ret := gosdf.Sm3Final(session)
	fmt.Printf("SM3 Final ret %d, hash: %x\n", ret, hash)
}
